package com.zerox.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * @author LYM
 * @version V1.11
 * @ClassName: HelloController
 * @Description:
 * @Date
 */
@Controller
public class HelloController  {
    @RequestMapping("/list")
    protected ModelAndView list(@RequestParam(required = false,defaultValue = "0") Integer id) throws Exception {
        ModelAndView modelAndView = new ModelAndView();
        System.out.println(id);
        modelAndView.setViewName("list.jsp");
        modelAndView.addObject("id",id);
        return modelAndView;
    }


    @RequestMapping("/list1")
    protected String list1(Model model, @RequestParam(required = false,defaultValue = "8") Integer id) throws Exception {
      model.addAttribute("id",id);
        return "list";
    }

    @RequestMapping("/list2")
    protected String list2(Map<String,Object> map, @RequestParam(required = false,defaultValue = "8") Integer id) throws Exception {
        map.put("id",id);
        return "list.jsp";
    }

    @RequestMapping("/add")
    protected ModelAndView add() throws Exception {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("add.jsp");
        return modelAndView;
    }

}
